export default {
    bind(el, binding, vnode) {
        function clickout(e) {
            if (el.contains(e.target)) {
                return false;
            }
            if (binding.expression) {
                binding.value(e);
            }
        }
        el._clickout = clickout;
        document.addEventListener('click', clickout, false);
    },
    unbind(el, binding, vnode) {
        document.removeEventListener('click', el._clickout, false);
        delete el._clickout;
    }
};